package com.fowo.api.service.handleWork;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fowo.api.entity.Ucp;
import com.fowo.api.mapper.UcpMapper;
import com.fowo.api.model.ucp.UcpUpdateStatusAction;
import com.fowo.api.service.impl.UcpServiceImpl;
import com.fowo.api.user.model.JwtUserInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class UcpUpdateStatus implements UcpUpdateStatusAction {
    @Resource
    private UcpServiceImpl ucpService;

    @Override
    public void run(List<Long> idList) throws Exception {
        JwtUserInfo currentUser = JwtUserInfo.fromHeader();
        ucpService.update(
                Wrappers.lambdaUpdate(Ucp.class)
                .in(Ucp::getId,idList)
                .set(Ucp::getStatus,"1")
                .set(Ucp::getUser,currentUser.getUserId()));
    }
}
